package com.hikvision.rpq.sblearn.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.format.annotation.DateTimeFormat;

import javax.annotation.PostConstruct;
import java.util.Date;

/**
 * @author renpeiqian
 * @date 2021/9/7 15:32
 * @since
 */
@Data
public class User implements BeanNameAware , BeanFactoryAware , ApplicationContextAware , InitializingBean {

    private String username;
    private String password;


    public User() {
    }

    public User(String username){
        this.username=username;
    }

    public User(String username,String password){

    }

    @DateTimeFormat(pattern = "yyyy-mm-dd&T&hh:mm:ss.sss")
    //@JsonFormat(pattern = "yyyy-mm-dd&T&hh:mm:ss.sss",timezone = "GMT+8")
    private Date birth;

    @Override
    public void setBeanName(String s) {
        System.out.println("注册我成为bean定义的id");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("管理我的beanFactory："+beanFactory);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("高级容器接口："+applicationContext);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet.....");
    }

    @PostConstruct
    public void  postConstruct(){
        System.out.println("postConstruct.....");
    }
}
